#include"common.hpp"
//客户端
int main()
{
    key_t key=GetKeyOrDie();
    //sleep(10);
    int shmid=GetSharedMemory(key,defaultsize);
    cout<<shmid<<endl;
    //开始挂接
    cout<<"开始挂接"<<endl;
    char*addr=(char*)AttachSharedMemory(shmid);
    if(addr==nullptr)
    {
        cout<<"挂接失败"<<endl;
    }
    cout<<addr<<endl;
    DeBug(shmid);
    //从共享内存中读数据
    memset(addr,'\0',defaultsize);
    while(true)
    {
        cout<<addr<<endl;
        if(strlen(addr)==26)break;
        sleep(1);
    }
    //取消挂接
    DetachShareMemory(addr);
    return 0;
}